package cn.iot.controller.sys;

import cn.iot.common.dto.ResultMsg;
import cn.iot.sys.entity.SysHostel;
import cn.iot.sys.service.SysHostelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/sys/hostel")
public class SysHostelController {
    @Autowired
    private SysHostelService sysHostelService;
    private Logger logger = LoggerFactory.getLogger(getClass());

    @PostMapping("getSysHostelList")
    public ResultMsg getSysHostelList(@RequestParam Map<String,Object> map){
        logger.info("SysHostelController getSysHostelList map{}",map);
        ResultMsg msg = sysHostelService.getSysHostelList(map);
        logger.debug("SysHostelController getSysHostelList msg{}",msg);
        return msg;
    }

    @PostMapping("addSysHostel")
    public ResultMsg addSysHostel(@RequestBody SysHostel sysHostel){
        logger.info("SysHostelController addSysHostel sysHostel{}",sysHostel);
        ResultMsg msg = sysHostelService.addSysHostel(sysHostel);
        logger.debug("SysHostelController addSysHostel msg{}",msg);
        return msg;
    }

    @PostMapping("updSysHostelById")
    public ResultMsg updSysHostelById(@RequestBody SysHostel sysHostel){
        logger.info("SysHostelController updSysHostelById sysHostel{}",sysHostel);
        ResultMsg msg = sysHostelService.updSysHostelById(sysHostel);
        logger.debug("SysHostelController updSysHostelById msg{}",msg);
        return msg;
    }

    @PostMapping("delSysHostelById")
    public ResultMsg delSysHostelById(@RequestParam int id){
        logger.info("SysHostelController delSysHostelById id{}",id);
        ResultMsg msg = sysHostelService.delSysHostelById(id);
        logger.debug("SysHostelController delSysHostelById msg{}",msg);
        return msg;
    }

    @PostMapping("getSysHostelAll")
    public ResultMsg getSysHostelAll(){
        logger.info("SysHostelController getSysHostelAll start");
        ResultMsg msg = sysHostelService.getSysHostelAll();
        logger.debug("SysHostelController delSysHostelById msg{}",msg);
        return msg;
    }

}
